package com.example.demo.controller;

import com.example.demo.entity.ResultMsg;
import com.example.demo.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author user
 */
@RequestMapping("order")
@RestController
@Slf4j
public class OrderController {
    @Resource
    private OrderService orderService;

    @PostMapping("insertOrder")
    public ResultMsg insertOrder(@RequestParam("companyId") Byte companyId,
                                 @RequestParam("userId") Long userId,
                                 @RequestParam("productId") Long productId,
                                 @RequestParam("amount") int amount) {

        return orderService.insertOrder(companyId, userId, productId, amount);
    }

    @GetMapping("detail")
    public ResultMsg detail(@RequestParam("orderId") Long orderId) {

        return orderService.detail(orderId);
    }
}
